import React, { Component } from 'react'
import { Form, Input, Tree } from 'antd'
import PropTypes from 'prop-types'
import menuList from '../../config/menuConfig.js'
export default class UpdateAuthForm extends Component {

  static propTypes= {
    role: PropTypes.object,
    getMenus: PropTypes.func
  }

  render() {
    const { role } = this.props
    return (
      <Form>
        <Form.Item 
          label="角色名称"
        >
          <Input 
            value={role.name}
            disabled
            style={{marginBottom: 20}}
          />
          <Tree
            checkable
            defaultCheckedKeys={role.menus}
            defaultExpandAll
            onCheck={checkedKeys => {this.props.getMenus(checkedKeys)}}
            treeData={menuList}
          />
        </Form.Item>
      </Form>
    )
  }
}
